
<template >
 <div class="common-layout">
    <el-container>
        <AsideVue/>
        <el-container>
        <el-header>首页
          <span @click="logout()" class="text-large font-600 mr-3"> 退出登录 </span>
        </el-header>
        <el-main>Main</el-main>
        </el-container>
    </el-container>
  </div>
</template>

<script setup lang="ts">
import AsideVue from "@/views/Aside.vue"
import {loginout} from "@/api/index.ts"
import {useRouter} from "vue-router"
import {removeToken } from "@/api/auth";
import {menuStore} from '@/stores/users.ts'
const router=useRouter();
let clearmenuStore=menuStore();
const logout = async () => {
  try {
   let {data}= await loginout();
    if(data && data.code===200){
       //清空token
        removeToken();
        //清空菜单
        clearmenuStore.navMenu=[];
        router.push('/login')
    }
  } catch (error) {
    //清空token
    removeToken();
    // 处理登录失败
    router.push('/login')
  }
}

</script>
<style scoped ">
.common-layout{
  height: 100%;
  :deep(.el-header){
    height: 70px;
    background-color:#2e537d;
  }
  :deep(.el-aside){
    height: 600px;
    background-color: #2e537d;
    &::-webkit-scrollbar{ 
      width: 0;
    }
  }
}
</style>